
    addEventListener("load", function() { setTimeout(updateLayout, 0); }, false);

    var currentWidth = 0;

    function updateLayout() {
        if (window.innerWidth != currentWidth) {
            currentWidth = window.innerWidth;
            document.getElementById('width').innerHTML = "[width = " + currentWidth + "px]";
            var orient = currentWidth == 320 ? "profile" : "landscape";
            document.body.setAttribute("orient", orient);
            setTimeout( function() { window.scrollTo(0, 1); }, 100);
        }
    }

    setInterval(updateLayout, 400);
    
    function hideURLbar() {
        window.scrollTo(0, 1);
    }

    if (navigator.userAgent.indexOf('iPhone') != -1) {
        addEventListener("load", function() { setTimeout(hideURLbar, 0); }, false);
    }
    